Skip to content

S-131984 26.1 purge script#48

Merged
lremedi merged 3 commits intomasterfrom
S-131984_Purge_Script
Apr 29, 2026
Merged

S-131984 26.1 purge script#48
lremedi merged 3 commits intomasterfrom
S-131984_Purge_Script

Conversation

@lremedi
Copy link
Copy Markdown
Contributor

@lremedi lremedi commented Apr 22, 2026

OKR Purge Logic Explanation

OKR entities are not scope-specific — none of them have a ScopeID. However, since we doom Members that are assigned only to doomed Scopes, we must cascade into OKR assets owned or authored by those doomed Members. Additionally, we must clean up many-to-many junction tables where either side of the relation is doomed.

Rack 'em Phase (Identification)

OwnerID is a required FK to Member. When a Member is doomed, their OkrObjectives become orphaned — they cannot exist without an owner.

OkrObjectiveID is a required FK. Once an OkrObjective is doomed, its KeyResults become orphaned — they cannot exist without their parent objective.

OkrComment has two required FKs: BelongsToID (to Okr) and AuthorID (to Member). Both are NOT NULL. If the parent Okr is doomed, the comment cannot exist. If the authoring Member is doomed, the comment also cannot exist. Either required FK being orphaned means the entity must be doomed.

Whack 'em Phase (Deletion)

OkrAssociatedAssets is a many-to-many junction linking Okrs to BaseAssets. When either side of the relation is doomed, the junction row is invalid and must be removed. We only remove the relation — we do NOT doom an Okr just because it is associated to a doomed BaseAsset.

OkrObjectiveSharedAccessWith is a many-to-many junction for shared access between OkrObjectives and Members. When either side is doomed, the junction row is invalid and must be removed.

OkrObjectiveLinkedFrom is a many-to-many self-referencing junction between OkrObjectives. If either linked objective is doomed, the link is invalid and must be removed.

OkrComments are removed by doomed ID. No nulling of AuthorID is needed because it is required (NOT NULL), and all comments with a doomed author were already doomed in the Rack 'em phase.

KeyResults are removed by doomed ID.

OkrObjectives are removed by doomed ID. CascadedFromID is an optional self-reference — a surviving objective could cascade from a doomed one, so it is nulled to avoid a dangling FK.

Okr is the base table that OkrObjective and KeyResult inherit from. After the derived type rows are deleted, the base Okr rows must also be removed. This goes last because children must be deleted before parents.

@lremedi lremedi merged commit 7979835 into master Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant